home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
AUTOCAD
/
H108.ZIP
/
JUL91.ZIP
/
SIPIPE.LSP
< prev
next >
Wrap
Text File
|
1991-09-26
|
7KB
|
253 lines
;SIPIPE.LSP [Article Figure 3] (c)1991, Barry Bowen
;--------------------------------------------------------------
; VARIABLES:
; ANG1 = Reset angle from PT1 to PT2
; ANG2 = Angle from the second line PT1 to PT2
; ANG3 = Angle from the first line PT1 to PT2
; ANG3A = Angle from the first line PT2 to PT1
; BANG = Break angle for ELUP fitting
; BM = Current blipmode setting
; BPT = Break point for ELUP fitting
; CL = Current layer name
; COLR = New layer color [Global]
; DIST = Distance from PTA to PTB
; FIT = Pipe fitting type
; FRZ = Variable for frozen layer check
; LAY = Variable for layer name check
; LIN = Last line drawn
; LT = Variable used for checking Linetype
; LTYP = Linetype for new layer [Global]
; NWLAY = New layer name [Global]
; PTA = Point on first line for locating fitting insertion
; PTB = Point on second line for locating fitting insertion
; PTC = Fitting insertion point
; PT1 = Pipe line begin point [Reset to PT2]
; PT2 = Pipe line ending point [Reset to PT1]
; SF = Linetype scale factor
; TANG = Test angle for EL90 and EL45 fittings
; VLIST = Current environment variables list
;--------------------------------------------------------------
(defun C:SLPIPE (/ ANG1 ANG2 ANG3 ANG3A BANG BM BPT CL DIST FIT
FRZ LAY LIN PTA PTB PTC PT1 PT2 TANG VLIST)
(V3)
(V1 '("osmode" "orthomode"))
(setvar "orthomode" 1)
(setvar "osmode" 0)
(if (= NWLAY nil) (NEWLAY))
(LS NWLAY COLR LTYP)
(if (= SF nil) (setq SF (getvar "ltscale")))
(FITTING)
(setq
PT1 (getpoint "\nPipe Begin Point: ")
PT2 (getpoint PT1 "\nNext point: ")
ANG2 (angle PT1 PT2)
ANG3 ANG2
ANG3A (angle PT2 PT1)
PTA (polar PT2 ANG3A 1)
)
(if (= FIT "TEE") (setq ANG3 (+ ANG3 pi)))
(setq
ANG3 (angtos ANG3 1 4)
ANG1 (angle PT1 PT2)
)
(if (/= FIT "NONE") (command ".insert" FIT PT1 SF SF ANG3))
(if (= FIT "ELUP") (setq PT1 (polar PT1 ANG1 (* SF 0.02))))
(command ".line" PT1 PT2 "")
(setq
PT1 PT2
LIN (entlast)
)
(while PT2
(setq PT2 (getpoint PT1 "\nNext Point: "))
(if (/= PT2 nil)
(progn
(setq
ANG2 (angle PT1 PT2)
ANG3 (angle PT2 PT1)
PTB (polar PT1 ANG2 1)
TANG (angle PTA PTB)
DIST (distance PTA PTB)
PTC (polar PTA TANG (/ DIST 2.0))
)
(cond
((= TANG (D45)) (setq FIT "EL90"))
((= TANG (D135)) (setq FIT "EL90"))
((= TANG (D225)) (setq FIT "EL90"))
((= TANG (D315)) (setq FIT "EL90"))
(T (setq FIT "EL45"))
)
(command
".insert" FIT PT1 SF SF PTC
".line" PT1 PT2 ""
)
(setq
LIN (entlast)
PT1 PT2
ANG1 ANG2
PTA (polar PT1 ANG3 1)
)
)
(progn
(FITTING)
(if (/= FIT "TEE") (setq ANG1 (+ ANG1 pi)))
(setq ANG1 (angtos ANG1 1 4))
(command ".insert" FIT PT1 SF SF ANG1)
)
)
)
(setq
BANG (+ ANG2 pi)
BPT (polar PT1 BANG (* SF 0.02))
)
(if (= FIT "ELUP") (command ".break" LIN PT1 BPT))
(RL)
(V1R)
(V4)
)
;----------------------- FITTING ----------------------------
; Pipe fittings (blocks) for SLPIPE program
;
(defun FITTING ()
(initget 1 "U D T C B N")
(setq FIT
(getkword "\n<U>p/<D>own/<T>ee/<C>ap/<B>rk/<N>one: ")
)
(cond
((= FIT "U") (setq FIT "ELUP"))
((= FIT "D") (setq FIT "ELDN"))
((= FIT "T") (setq FIT "TEE"))
((= FIT "C") (setq FIT "CAP"))
((= FIT "B") (setq FIT "BRK"))
((= FIT "N") (setq FIT "NONE"))
)
)
;-------------------- Routines For Angles -------------------
;
(defun D45 () (* pi 0.25))
(defun D90 () (* pi 0.5))
(defun D135 () (* pi 0.75))
(defun D225 () (* pi 1.25))
(defun D270 () (* pi 1.5))
(defun D315 () (* pi 1.75))
(defun A180 () (+ ANG pi))
;------------------------- V1.LSP ---------------------------
; Change environment variables
;
(defun V1 (SV)
(setq VLIST '())
(while SV
(setq
VLIST (append VLIST
(list (list (car SV) (getvar (car SV))))
)
SV (cdr SV)
)
)
)
;------------------------- V1R.LSP --------------------------
; Reset environment variables changed by "V1"
;
(defun V1R ()
(while VLIST
(setvar (caar VLIST) (cadar VLIST))
(setq VLIST (cdr VLIST))
)
)
;------------------------- V3.LSP ---------------------------
; Start-up routine
;
(defun V3 ()
(setq BM (getvar "blipmode"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
(command ".undo" "group")
)
;------------------------- V4.LSP ---------------------------
; Ending routine
;
(defun V4 (/ BA)
(setvar "blipmode" BM)
(command ".undo" "end")
(prompt "\n")
(setq BA "Program Completed. . . . .")
)
;------------------------ NEWLAY ----------------------------
; Used with "LS" for creating new Layer/Color/Linetype
;
(defun NEWLAY ()
(setq
NWLAY (getstring "\nNew Layer Name: ")
COLR (getstring "\nColor Number <7>: ")
LTYP (getstring "\nLinetype <Continuous>: ")
)
(if (= LTYP "") (setq LT "continuous") (setq LT LTYP))
(while (= (tblsearch "LTYPE" LT) nil)
(prompt (strcat "\nLinetype " LT " not found!"))
(setq LTYP (getstring "\nLinetype <Continuous>: "))
(if (= LTYP "") (setq LT "continuous") (setq LT LTYP))
)
(if (= LTYP "") (setq LTYP ""))
(if (= COLR "") (setq COLR "7"))
)
;--------------------------- LS -----------------------------
; Creates new layer with color and linetype from "NEWLAY"
;
(defun LS (NLAY CLR LT)
(setq
CL (getvar "clayer")
LAY (tblsearch "layer" NLAY)
)
(if (not LAY)
(command ".layer" "m" NLAY "c" CLR "" "lt" LT "" "")
(progn
(setq FRZ (cdr (assoc 70 LAY)))
(if (= FRZ 65)
(command ".layer" "t" NLAY "s" NLAY "")
(command ".layer" "s" NLAY "")
)
)
)
)
;--------------------------- RL -----------------------------
; Resets the previous layer to the current layer.
;
(defun RL ()
(command ".layer" "s" CL "")
)
;------------------------- *ERROR* --------------------------
; Error routine
(defun *error* (MSG)
(princ "error: ")
(princ MSG)
(RL)
(V1R)
(V4)
)
(prompt "\nSingle Line Piping Program SLPIPE is Now Loaded!")
(princ)